package com.lwl.blue.commont.config;

import com.lwl.blue.commont.base.Const;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * <p>自定义拦截器配置类    </p>
 *
 * @version: V1.0
 * @author: <a href=mailto:lanwenliang@yidianlife.com>蓝文良</a>
 */
@Configuration
@EnableWebMvc
public class MySpringBootFilterConfig implements WebMvcConfigurer {
    @Value("${upload.filePath}")
    private String filePath;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
//        resolvers.add(headerTokenInterceptor);
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //将所有/static/**访问都映射到classpath:/static/目录下
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
        String path;
        //linux 和 windows 环境不同的配置方式
        if (-1 != System.getProperty("os.name").indexOf("Win")) {
            path = "file:/" + filePath;
        } else {
            path = "file:"+filePath;
        }
        registry.addResourceHandler("/export/**")
                .addResourceLocations(path);

    }
}
